home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / boot / czesc_2 / smsrc / sm / startup-menu.pas < prev    next >
Pascal/Delphi Source File  |  1995-07-11  |  5KB  |  162 lines

  1. {$F-,I-,R-,S-,V-,M 7,1,5,15}
  2.  
  3. {$I SM.h }
  4.  
  5. Procedure Main;
  6.  
  7. CONST
  8.     rc        : shortint = 10;
  9.     RD_Array  : Array[1..2] of LongInt = (0,0);
  10.     Template  : String[19] = 'PREFSFILE,NOQUAL/S'#0;
  11.     PREFSFILE = 1;
  12.     NOQUAL = 2;
  13.     waitpointerdata : tPointerArray = ($0000, $0000,
  14.  
  15.                                       $0400, $07c0,
  16.                                       $0000, $07c0,
  17.                                       $0100, $0380,
  18.                                       $0000, $07e0,
  19.                                       $07c0, $1ff8,
  20.                                       $1ff0, $3fec,
  21.                                       $3ff8, $7fde,
  22.                                       $3ff8, $7fbe,
  23.                                       $7ffc, $ff7f,
  24.                                       $7efc, $ffff,
  25.                                       $7ffc, $ffff,
  26.                                       $3ff8, $7ffe,
  27.                                       $3ff8, $7ffe,
  28.                                       $1ff0, $3ffc,
  29.                                       $07c0, $1ff8,
  30.                                       $0000, $07e0,
  31.  
  32.                                       $0000, $0000); 
  33. VAR
  34.     s     : String;
  35.     ok    : boolean;
  36.     n     : integer;
  37.     RDArg : pRDArgs;
  38.     tn    : pMyNode;
  39.     port  : pMsgPort;
  40.     ior   : PIORequest;
  41.     
  42.     pq : LONG;
  43.     
  44. Begin
  45.     { open libraries }
  46.     if Open_Libs then begin
  47.         begin
  48.             { alloc chip mem for waitpointer }
  49.             waitpointer := AllocRemember(@RememberKey, sizeof(tPointerArray), MEMF_CHIP);
  50.             if waitpointer <> NIL then begin
  51.                 { copy data into memory }
  52.                 WaitPointer^ := WaitpointerData;
  53.                 OK := false;
  54.  
  55.                 s := PREFSDIRH+PREFSNAME;
  56.                 FORCEQ := false;
  57.                 RDArg := NIL;
  58.                 If CmdLinePtr.Len >= 1 then begin
  59.                     RDArg := ReadArgs(@Template[1],@RD_Array,NIL);
  60.                     If RDArg <> NIL then begin
  61.                         if RD_Array[PREFSFILE] <> 0 then 
  62.                             s := PtrToPas(Pointer(RD_Array[PREFSFILE]));
  63.                     
  64.                         if RD_Array[NOQUAL] <> 0 then FORCEQ := True;
  65.                     End;
  66.                 End;
  67.  
  68.                 if ReadConfigFile(s) then begin
  69.                 
  70.                     if (CD.cd_Test = False) then begin
  71.                         ToggleClick(CD.cd_NoClick);
  72.                         ToggleWildStar(CD.cd_WildStar);
  73.                         TogglePubFlags(CD.cd_Shanghai, CD.cd_PopPubScr);
  74.                     end;
  75.                 
  76.                     OK := False;
  77.                     If NOT FORCEQ then begin
  78.                         port := CreateMsgPort;
  79.                         if port <> NIL then begin
  80.                             ior := CreateIORequest(port, Sizeof(tIORequest));
  81.                             if ior <> NIL then begin
  82.                                 if OpenDevice('input.device', 0, ior, 0) = 0 then begin
  83.                                     InputBase := pLibrary(ior^.io_Device);
  84.                                     pq := PeekQualifier;
  85.                                     if CD.cd_Quals <> 0 then begin
  86.                                         Case CD.cd_App of
  87.                                             APP_ALL : begin
  88.                                                 if pq and CD.cd_Quals = CD.cd_Quals then
  89.                                                 OK := True;
  90.                                             End;
  91.                                             APP_ONE : begin
  92.                                                 if pq and CD.cd_Quals <> 0 then
  93.                                                 OK := True;
  94.                                             End;
  95.                                             Else OK := True;
  96.                                         End;
  97.                                     end else
  98.                                         OK := True;
  99.                                     CloseDevice(ior);
  100.                                 end;
  101.                                 DeleteIORequest(ior);
  102.                             end;
  103.                             DeleteMsgPort(port);
  104.                         end;
  105.                     end else OK := True;
  106.                 
  107.                     FreeArgs(RDArg);
  108.                 
  109.                     InitLogFile(lf, CD.cd_LogFIle);
  110.                     
  111.                     if OK then begin
  112.                         if CurrentList^.lh_Head^.ln_Succ <> NIL then begin
  113.                             
  114.                             InitRequester(@DummyReq);
  115.                             If CD.cd_Test then begin
  116.                                 ReqToolsBase := pReqToolsBase(OpenLibrary(REQTOOLSNAME,REQTOOLSVERSION));
  117.                                 If ReqToolsBase = NIL Then 
  118.                                     CD.cd_Test := False;
  119.                             end;
  120.                             if CD.cd_Wit then
  121.                                 CD.cd_WitTxt := GetWitComment
  122.                             else
  123.                                 CD.cd_WitTxt := '';
  124.                         
  125.                             TheScreen := Open_Screen;
  126.                             if TheScreen <> NIL then begin
  127.                                 if CD.cd_Rexx then
  128.                                     SendARexxCommand(CD.cd_RexxCmd1, CD.cd_RexxPort1);
  129.                                 TheWindow := Open_Window;
  130.                                 if TheWindow <> NIL then begin
  131.                                     rc := HandleIDCMP;
  132.                                     Close_window;
  133.                                 end;
  134.                                 if CD.cd_Rexx then
  135.                                     SendARexxCommand(CD.cd_RexxCmd2, CD.cd_RexxPort2);
  136.                                 Close_Screen;
  137.                             end;
  138.                             if CD.cd_Test then CloseLibrary(pLibrary(ReqtoolsBase));
  139.                         end;{ else writeln('list empty');}
  140.                     end else WriteLogFile(lf, NIL, True);
  141.                     FreeLogFile(lf);
  142.                 end;
  143.             end;
  144.         end;
  145.         If CD.cd_Flush then begin
  146.             tn := AllocRemember(@RememberKey, sizeof(tMyNode), MEMF_CLEAR);
  147.             if tn <> NIL then begin
  148.                 tn^.LSK_Cmd[0] := 'C:';
  149.                 tn^.LSK_Cmd[1] := 'Avail FLUSH';
  150.                 tn^.LSK_Output := 'NIL:';
  151.                 tn^.LSK_Asynch := False;
  152.                 
  153.                 ok := StartCLIProgram(tn);
  154.             end;
  155.         end;
  156.         FreeRemember(@RememberKey, True);
  157.         Close_Libs;
  158.     end;
  159.     halt(rc);
  160. end;
  161.  
  162. begin main end.